import React from "react";
import { Link, useRoutes } from "react-router-dom";
import routes from "./router/index";

const App = () => {
  const element = useRoutes(routes);
  return (
    <>
      <h2>路由懒加载</h2>
      <ul>
        <li>
          <Link to="/home">首页</Link>
        </li>
        <li>
          <Link to="/about">关于页</Link>
        </li>
      </ul>

      <hr />

      {/* 当路由的任意部分发生改变，整个页面都loading */}
      {/* <Suspense fallback={<div>loading...</div>}>{element}</Suspense> */}

      {element}
    </>
  );
};

export default App;
